/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package diagram.locations;

import java.io.Serializable;

/**
 *
 * @author Jelle
 */
public class VerticalLineLocation  implements Location, Serializable {
    protected Location location;
    protected Location location1;
    protected Location location2;

    public VerticalLineLocation(Location location, Location location1, Location location2) {
        this.location = location;
        this.location1 = location1;
        this.location2 = location2;
    }

    public int getX() {
        return location.getX();
    }

    public int getY() {
        return location.getY();
    }

    public void setXY(int x, int y) {
        int xx = location1.getX();
        int minY = Math.min(location1.getY(), location2.getY());
        int maxY = Math.max(location1.getY(), location2.getY());
        location.setXY(xx, y < minY ? minY : (y > maxY ? maxY : y));
    }

    /**
     * to be called when reference locations change
     */
    public void update() {
        this.setXY(this.getX(), this.getY());
    }

    public void print(){
    }
}
